# 5）租房方式（饼图）【整租还是合租】title
import pandas as pd
from pyecharts import options as opts
from pyecharts.charts import Pie


df = pd.read_excel('data_clean.xlsx')
data2 = df[~df.title.isin([0])]
location_list = []
for location in data2['title']:
    location = location[0:2]
    location_list.append(location)
data2['location'] = location_list
locations = [location for location in data2['location'].value_counts().items()]

c = (
    Pie()
    .add("", locations)
    .set_global_opts(title_opts=opts.TitleOpts(title="Pie-设置颜色"))
    .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
    .render("pie_set_color.html")
)